//
//  Status.swift
//  WeiBo
//
//  Created by Tony on 2018/1/22.
//  Copyright © 2018年 Tony. All rights reserved.
//

import UIKit

class Status: NSObject {

    // 微博创建时间
    var created_at : String? /*{
        
        didSet {
            guard let created_at = created_at else {
                return
            }
            
            created_atText = Date.createDateString(created_at)
        }
    }*/
    
    // 微博来源
    var source : String? /*{
        didSet {
            guard let source = source, source != "" else {
                return
            }
            
            let startIndex = (source as NSString).range(of: ">").location + 1
            let length = (source as NSString).range(of: "</").location - startIndex
            
            sourceText = (source as NSString).substring(with: NSRange.init(location: startIndex, length: length))
        }
    }*/
    
    // 微博正文
    var text : String?
    
    // 微博mid
    var mid : String?
    
    // 用户
    var user : User?

    // 数据处理
    /*
    var sourceText: String?
    var created_atText: String?
    */
    
    // 初始化
    init(dict: [String : AnyObject]) {
        super.init()
        
        setValuesForKeys(dict)
        
        let userDict: [String : Any] = dict["user"] as! [String : Any]
        user = User.init(dict: userDict)
        
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {}
    
    override var description: String {
        return dictionaryWithValues(forKeys: ["created_at","source","text","mid","sourceText"]).description

    }
    
}
